# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=rage
pkgver=0.9.2
pkgrel=1
pkgdesc="Simple, modern and secure encryption tool"
url="https://github.com/str4d/rage"
license="Apache-2.0 OR MIT"
arch="all !s390x !riscv64" # blocked by rust/cargo
makedepends="cargo fuse3-dev cargo-auditable"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/str4d/rage/archive/v$pkgver/rage-$pkgver.tar.gz
	fix-build-32bit.patch
	"


prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo auditable build --frozen --release --features mount

	cargo run --frozen --release --example generate-docs
	cargo run --frozen --release --example generate-completions
}

check() {
	cargo test --frozen --features mount
}

package() {
	for cmd in rage rage-keygen rage-mount; do
		install -Dm755 target/release/$cmd -t "$pkgdir"/usr/bin

		install -Dm644 target/manpages/$cmd.1.gz -t "$pkgdir"/usr/share/man/man1

		install -Dm644 target/completions/$cmd.bash \
			"$pkgdir"/usr/share/bash-completion/completions/$cmd
		install -Dm644 target/completions/$cmd.fish \
			"$pkgdir"/usr/share/fish/vendor_completions.d/$cmd.fish
		install -Dm644 target/completions/$cmd.zsh \
			"$pkgdir"/usr/share/zsh/site-functions/_$cmd
	done
}

sha512sums="
ec44929b01e75366f9c0a41f4bf0b5dff256a8cdb1fb67461cc29fc9a90c9fd3936017e64fb427e8303c02380c841b82955c9f3aee90f3bdb1081a3cdfae2a34  rage-0.9.2.tar.gz
eabd51083c59450ac4e5aae5f499b8ef657d70fbde1d78322ec56790a52485ae93b006b5255053d2bc5313e4352610aa5cd60b994496a45196db9a2de190d417  fix-build-32bit.patch
"
